import { store } from "@/store";
import { ref } from "vue";
import { defineStore } from "pinia";
import { WebsiteEnum } from "@/enums/website/website-enum";
import { WebsiteType } from "@/types/website";

export const useWebsiteStore = defineStore("website", () => {
  // 用户信息
  const website = ref<WebsiteType>({
    logo: WebsiteEnum.LOGO,
    nameSpace: WebsiteEnum.NAME_SPACE,
  } as WebsiteType);
  const setWebsite = (val: WebsiteType) => {
    website.value = val;
  };
  const getWebsite = () => {
    return website.value;
  };
  return {
    website,
    setWebsite,
    getWebsite,
  };
});

/**
 * 在组件外部使用useWebsiteStore的钩子函数
 * @see https://pinia.vuejs.org/core-concepts/outside-component-usage.html
 */
export function useWebsiteStoreHook() {
  return useWebsiteStore(store);
}
